<!--
 * @Author: wjk
 * @Date: 2019-12-31 15:40:51
 * @LastEditors: wjk
 * @LastEditTime: 2020-11-10 16:20:48
 * @description: file content
 -->
<template>
  <base-page-view class-name="page-container mine_order">
    <view class="order-box">
      <view class="title">
        我的订单
        <span @click="orderClick(allOrder)">全部订单 <image src="/static/images/mine/icon_my_more.png" alt="" class="icon_my_more" /></span>
      </view>
      <view class="orderControls">
        <view v-for="(item, index) in ctItems" :key="index" class="ctItem" @click="orderClick(item, index)">
          <view class="card">
            <image :src="item.image" class="imgs" mode="aspectFit" />
            <view v-if="item.num > 0" class="card_tips">
              <span :class="{two: item.num > 9}">{{ item.num > 99 ? '99': item.num }}</span>
            </view>
          </view>
          <span v-html="item.title">待付款</span>
        </view>
      </view>
    </view>
    <view class="order-box">
      <view class="title">
        其它订单
      </view>
      <view class="orderControls">
        <view v-for="(item, index) in tkItems" :key="index" class="ctItem" @click="orderClick(item, index)">
          <view class="card">
            <image :src="item.image" class="imgs" />
          </view>
          <span v-html="item.title">待付款</span>
        </view>
        <view class="ctItem"></view>
        <view class="ctItem no-border"></view>
      </view>
    </view>
  </base-page-view>
</template>

<script>
import './index.scss'
export default {
  components: {
  },
  data() {
    return {
      allOrder: {
        title: '全部订单',
        path: '/pagesOrder/order/index?type=0',
        image: '/static/images/mine/icon_my_successful.png'
      },
      ctItems: [
        {
          title: '待付款',
          path: '/pagesOrder/order/index?type=1',
          image: '/static/images/mine/icon_my_payment.png',
          num: 0
        },
        {
          title: '待分享',
          path: '/pagesOrder/order/index?type=11',
          image: '/static/images/mine/icon_my_share.png',
          num: 0
        },
        {
          title: '待发货',
          path: '/pagesOrder/order/index?type=2',
          image: '/static/images/mine/icon_my_delivery.png',
          num: 0
        },
        {
          title: '待收货',
          path: '/pagesOrder/order/index?type=3',
          image: '/static/images/mine/icon_my_takedelivery.png',
          num: 0
        },
        {
          title: '待评价',
          path: '/pagesOrder/order/index?type=4',
          image: '/static/images/order/icon_evaluate_comment.png',
          num: 0
        }
        // {
        //   title: '全部订单',
        //   path: '/order/mine/0',
        //   image: require('@/assets/images/mine/icon_my_successful.png')
        // }
        // ,
        // {
        //   title: '退货退款',
        //   path: '/order/mine/5',
        //   image: require('@/assets/images/mine/icon_my_successful.png')
        // }
      ],
      tkItems: [
        {
          title: '拼多多',
          path: '/pagesOrder/pddOrder/index?platform=PDD',
          image: '/static/images/commission/pdd.png'
        },
        {
          title: '京东',
          path: '/pagesOrder/pddOrder/index?platform=JD',
          image: '/static/images/commission/jd.png'
        },
        {
          title: '唯品会',
          path: '/pagesOrder/pddOrder/index?platform=VOP',
          image: '/static/images/commission/vop.png'
        }
      ]
    }
  },
  created() {
  },
  onLoad() {
    // this.setRedPoint()
  },
  onShow() {
    this.setRedPoint()
  },
  methods: {
    setRedPoint() {
      if (!this.$store.state.setting && !this.$store.state.setting.order_status_num) {
        return
      }
      this.ctItems.filter(item => {
        switch (item.title) {
          case '待付款':
            item.num = this.$store.state.setting.order_status_num.wait_payment
            break
          case '待分享':
            item.num = this.$store.state.setting.order_status_num.wait_share
            break
          case '待发货':
            item.num = this.$store.state.setting.order_status_num.wait_consign
            break
          case '待收货':
            item.num = this.$store.state.setting.order_status_num.wait_take
            break
          case '待评价':
            item.num = this.$store.state.setting.order_status_num.non_comment
            break
          default:
            break
        }
      })
    },
    orderClick(item) {
      this.$navigateTo(item.path)
    }
  }
}
</script>
